import '../app/models/download.dart';
import '/app/controllers/downloader_controller.dart';
import '/app/controllers/category_controller.dart';
import '/app/controllers/settings_controller.dart';
import '/app/controllers/play_controller.dart';
import '/app/networking/search_movie_api_service.dart';
import '../app/models/movie.dart';
import '/app/controllers/search_movie_controller.dart';
import '/app/controllers/dashboard_controller.dart';
import '/app/networking/subcategory_api_service.dart';
import '../app/models/subcategory.dart';
import '/app/networking/category_api_service.dart';
import '../app/models/category.dart';
import '/app/controllers/home_controller.dart';
import '/app/models/user.dart';
import '/app/networking/api_service.dart';

/* Model Decoders
|--------------------------------------------------------------------------
| Model decoders are used in 'app/networking/' for morphing json payloads
| into Models.
|
| Learn more https://nylo.dev/docs/6.x/decoders#model-decoders
|-------------------------------------------------------------------------- */

final Map<Type, dynamic> modelDecoders = {
  Map<String, dynamic>: (data) => Map<String, dynamic>.from(data),

  List<User>: (data) =>
      List.from(data).map((json) => User.fromJson(json)).toList(),
  //
  User: (data) => User.fromJson(data),

  // User: (data) => User.fromJson(data),

  List<Category>: (data) =>
      List.from(data).map((json) => Category.fromJson(json)).toList(),

  Category: (data) => Category.fromJson(data),

  List<Subcategory>: (data) =>
      List.from(data).map((json) => Subcategory.fromJson(json)).toList(),

  Subcategory: (data) => Subcategory.fromJson(data),

  List<Movies>: (data) =>
      List.from(data).map((json) => Movies.fromJson(json)).toList(),

  Movies: (data) => Movies.fromJson(data),

  List<Download>: (data) =>
      List.from(data).map((json) => Download.fromJson(json)).toList(),

  Download: (data) => Download.fromJson(data),
};

/* API Decoders
| -------------------------------------------------------------------------
| API decoders are used when you need to access an API service using the
| 'api' helper. E.g. api<MyApiService>((request) => request.fetchData());
|
| Learn more https://nylo.dev/docs/6.x/decoders#api-decoders
|-------------------------------------------------------------------------- */

final Map<Type, dynamic> apiDecoders = {
  ApiService: () => ApiService(),

  // ...

  CategoryApiService: CategoryApiService(),

  SubcategoryApiService: SubcategoryApiService(),

  SearchMovieApiService: SearchMovieApiService(),
};

/* Controller Decoders
| -------------------------------------------------------------------------
| Controller are used in pages.
|
| Learn more https://nylo.dev/docs/6.x/controllers
|-------------------------------------------------------------------------- */
final Map<Type, dynamic> controllers = {
  HomeController: () => HomeController(),
  DashboardController: () => DashboardController(),
  SearchMovieController: () => SearchMovieController(),
  PlayController: () => PlayController(),
  SettingsController: () => SettingsController(),
  CategoryController: () => CategoryController(),
  DownloaderController: () => DownloaderController(),
};
